<%@ include file="/common/taglibs.jsp"%>
<c:set var="shoppingCartUrl"><spring:url value="/shoppingCart/addBook.html">
	<spring:param name="bookId" value="${book.id}"/>
</spring:url></c:set>
<head>
	<title><spring:message code="book.details.header"/> | <c:out value="${book.name}" /></title>
	<script type="text/javascript">
	$(document).ready(function(){
		$("#buyThisBook").click(function() {
			location.assign("${shoppingCartUrl}");
		});
	});
	</script>
</head>
<div class="ui-widget summary-booklist">
	<h1 class="ui-helper-reset ui-widget-header ui-corner-top booklist-header">
		<spring:message code="book.details.header"/>
	</h1>
	<div class="ui-widget-content ui-corner-bottom">
		<table width="100%">
			<tr>
				<td>
					<table>
						<tr>
							<td rowspan="11"><img width="200px" height="270px" style="margin: 5px;" src="${book.image}"/></td>
							<td colspan="2"><h1><c:out value="${book.name}"/></h1></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.authorName"/></td>
							<td><c:forEach items="${book.authors}" var="author" varStatus="loopStatus">
								<c:choose>
									<c:when test="${loopStatus.last}">
										<c:out value="${author.name}"/>
									</c:when>
									<c:otherwise>
										<c:out value="${author.name},"/>
									</c:otherwise>
								</c:choose>
							</c:forEach></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.publisherName"/></td>
							<td><c:out value="${book.publisher.userAccount.name}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.publishDate"/></td>
							<td><fmt:formatDate value="${book.publishDate}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.fixedPrice"/></td>
							<td>&#36;<c:out value="${book.fixedPrice}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.unitPrice"/></td>
							<td class="book-price">&#36;<c:out value="${book.unitPrice}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.locale"/></td>
							<td><c:out value="${book.locale}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.pages"/></td>
							<td><c:out value="${book.pages}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.isbn"/></td>
							<td><c:out value="${book.isbn}"/></td>
						</tr>
						<tr>
							<td><spring:message code="book.details.ean"/></td>
							<td><c:out value="${book.ean}"/></td>
						</tr>
						<tr>
							<td style="color: red;"><spring:message code="${sf:getInventoryStatusMessageCode(book.inventory.status)}"/></td>
							<td><c:choose>
							<c:when test="${'INACTIVE' == book.inventory.status || 'OUT_OF_PRINT' == book.inventory.status}">
								<button id="buyThisBook" class="aButton" disabled="disabled"><spring:message code="book.details.putInShoppingCart"/></button>
							</c:when>
							<c:otherwise>
								<button id="buyThisBook" class="aButton" ><spring:message code="book.details.putInShoppingCart"/></button>
							</c:otherwise>
							</c:choose></td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td><h2><spring:message code="book.details.description"/></h2></td>
			</tr>
			<tr><td class="ui-helper-reset">${book.description}</td></tr>
		</table>
	</div>
</div>
